package collections3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionsDemo {

	public static void main(String[] args) {

		/*
		 * 对学员集合进行排序：根据年龄升序排序
		 */

		List<Students> stus = new ArrayList<Students>();
		stus.add(new Students(32, "张三", "男", 12));
		stus.add(new Students(3, "李四", "女", 15));
		stus.add(new Students(13, "王五", "男", 10));

		for (int i = 0; i < stus.size(); i++) {
			Students stu = stus.get(i);
			String info = stu.getId() + "-" + stu.getName() + "-" + stu.getGender() + "-" + stu.getAge();
			System.out.println(info);
		}

		System.out.println("************************");
		Collections.sort(stus);

		for (int i = 0; i < stus.size(); i++) {
			Students stu = stus.get(i);
			String info = stu.getId() + "-" + stu.getName() + "-" + stu.getGender() + "-" + stu.getAge();
			;
			System.out.println(info);
		}
	}
}
